<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>非空元素查找</title>
		<link rel="stylesheet" type="text/css" href="css/txt.css" />
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>

		<div>
				<span></span>
				<div>1. helloWorld</div>
		</div>
		<p></p>

	</body>

	<script type="text/javascript">
		$(function() {
			// 查找div中的非空元素，并设置样式txt
			$("div:parent").attr("class","txt");
		});
	</script>

</html>